﻿
/***********************************************/
//当前页面实例
var currentPage;
//控件集合实例
var controlsCollection;

$(document).ready(function () {
    var collection = [
        New(ASPxRFTextBox, ['txtPageCode', ['GroupA'], 'PageCode']),
        New(ASPxRFTextBox, ['txtPageName', ['GroupA'], 'PageName']),
        New(ASPxRFComboBox, ['cbModule', ['GroupA'], { textField: 'ModuelName', valueField: 'ModuleKeyid'}])
    ];
    controlsCollection = New(RapidForm, [collection]);
    //声明页面信息
    var navigationInfo = { moduleValue: 'Permission', itemValue: 'RoleItem', itemName: '岗位明细' };
    currentPage = New(RFPage, [menuHeader, gvwList, [], [], null, navigationInfo]);
    currentPage.firstLoad();
});

//选择模块
var doSelectedIndexChanged = function (s, e) {
    var keyid = s.GetSelectedItem().value;
    if (keyid == 'none') {
        $('#hfModuleFilterCondition').val('');
    } else {
        $('#hfModuleFilterCondition').val('Keyid=' + keyid);
    }
    gvwPageList.PerformCallback();
}

//配置快捷方式
var doCheckedChanged_Page = function (s, e) {
    var isSelected = s.GetChecked();
    var obj = s.GetMainElement();
    var pageKeyid = $('> .keyidField', obj.parentNode).text();

    SGDemo.Permission.ShortcutsList.CheckedChangedPage(pageKeyid, isSelected, function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '操作成功!'
            });
        } else {
            $.messager.show({
                title: '信息提示',
                msg: '操作失败!'
            });
        }
    });
}
/***********************************************/

//查找提交
function doSubmittedToSearch(s, e) {
    doListAll();
    $('#hfFilterCondition').val(controlsCollection.getQueryString('GroupA'));
    gvwList.PerformCallback();
}
//查找重置
var doResetToSearch = function (s, e) {
    controlsCollection.reset('GroupA');
}

/***********************************************/



//查找
var doSearch = function () {
    doDisplay('search');
    currentPage.toSearch();
}
//显示所有
var doListAll = function () {
    doDisplay('listall');
    currentPage.toListAll();
}
//刷新
var doRefresh = function () {
    $('#hfFilterCondition').val(' ')
    gvwList.PerformCallback();
}
//导出数据
var doExport = function () {
    pcExport.Show();
}
//关闭导出数据窗口
var doCloseToExport = function () {
    pcExport.Hide();
}
//打印
var doPrint = function () {
    window.print();
}

//添加快捷方式
var doSetShortcut = function () {
    SGDemo.Permission.ShortcutsList.SaveFastAdd(function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式成功！',
                showType: 'slide'
            });

        } else {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式失败！',
                showType: 'slide'
            });
        }

    });
}

//GridView选中全部或者取消选中全部
var doSelectOrUnselectAll = function (s, e) {
    gvwList.SelectAllRowsOnPage(s.GetChecked());
}

//删除
var doBulkDelete = function () {
    $.messager.confirm('确认提示', '确认删除吗?', function (result) {
        if (result) {
            var keyids = gvwList.GetSelectedKeysOnPage().join('_');
            SGDemo.Permission.ShortcutsList.BulkDelete(keyids, function (result) {
                if (result.value) {
                    gvwList.PerformCallback();
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除成功！',
                        showType: 'slide'
                    });
                } else {
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除失败！',
                        showType: 'slide'
                    });
                }
            });
        }
    });
}

